package com.hanxiaozhang.base.dao;

import com.hanxiaozhang.base.dto.JobTaskDTO;
import com.hanxiaozhang.base.entity.JobTaskEntity;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 定时任务
 *
 * @author hanxiaozhang
 * @email hanxiaozhang2018@sina.com
 * @date 2021-04-29
 * @since 1.0.0
 */
@Mapper
public interface JobTaskDao {

    JobTaskEntity get(Long id);

    List<JobTaskDTO> list(Map<String, Object> map);

    int save(JobTaskEntity jobTask);

    int update(JobTaskEntity jobTask);

    int remove(Long id);

    int batchRemove(Long[] ids);


    @Update("update `base_job_task` set `job_status` = #{jobStatus}  where `del_flag` = 0 and  id = #{id}")
    int updateStatusById(@Param("id") Long id, @Param("jobStatus") Integer jobStatus);

    @Select("select  *  from `base_job_task`  where   `del_flag` = 0 and  `bean_class` = #{beanClass}")
    JobTaskEntity getByBeanClass(@Param("beanClass") String beanClass);

    @Select("select  *  from `base_job_task`  where   `del_flag` = 0  and  `bean_class` = #{beanClass} and id != #{id}")
    JobTaskEntity getByBeanClassNotId(@Param("beanClass") String beanClass, @Param("id") Long id);

}
